package cwb1;

import java.util.HashMap;
import java.util.Map;

/**
 * This class represents a course of the university. A course contains a name, id, an instructor and an amount of studyPoints.
 * The course is also a data form that can stored in the database.
 * 
 * @author Aurora
 *
 */
public class Course extends Division
{
	
	//The name of the course.
	private String courseName;
	//The instructor of the course.
	private String instructor;
	//The amount of studyPoints of the course.
	private long studyPoints;
	
	//the amount of fields passed to the database.
	private final static int AMOUNT_OF_IMPORTANT_FIELDS = 3;
	
	/**
	 * Creates a new Course object.
	 * 
	 * @param courseName The name of the course.
	 * @param instructor The instructor of the course.
	 * @param courseId The Id of the course.
	 * @param studyPoints The amount of studyPoints of the course.
	 */
    public Course(String courseName, String instructor, String courseId, long studyPoints) {
    	super(courseId, DivisionFactory.COURSE);
    	this.courseName = courseName;
    	this.instructor = instructor;
    	this.studyPoints = studyPoints;
        }
    
    /**
     * Creates a new Course object using a Map with the values for the fields. Be warned their is no control if the keys match the fieldnames.
     * 
     * @param properties a Map containing the next keys: "courseName" with String, "instructor" with String, "courseId" with String, "studyPoints" with Long
     */
    public Course(Map<String,Object> properties)
    {
    	super(properties);
    	courseName = (String) properties.get("courseName");
    	instructor = (String) properties.get("instructor");
    	studyPoints = (Long) properties.get("studyPoints");
    	
    	
    	
    }
    
    /**
     * Returns a HashMap with the fields of the course and as key the name of fields.
     * 
     * @return A HashMap containing the fields of the course.
     */
    public HashMap<String,Object> getProperties()
    {
    	HashMap<String, Object> properties = super.getProperties();
    	
    	properties.put("courseName", courseName);
    	properties.put("instructor", instructor);
    	properties.put("studyPoints",studyPoints);
    	    	
    	return properties;
    }
    
    /**
     * Returns the courseName
     * 
     * @return The name of the course.
     */
    public String getCourseName()
    {
    	return courseName;
    }
    
    /**
     * Returns the instructor of the course.
     * 
     * @return The instructor of the course.
     */
    public String getInstructor()
    {
    	return instructor;
    }
    
    /**
     * Returns the amount of studyPoints of the course.
     * 
     * @return The amount of studyPoints of the course.
     */
    public long getStudyPoints()
    {
    	return studyPoints;
    }
	
	@Override
	public int getAmountOfFields() {
		return AMOUNT_OF_IMPORTANT_FIELDS;
	}
   
}
